package com.elysia.adminservice.service.impl;

import com.elysia.adminservice.enumeration.ResourceTypeEnum;
import com.elysia.adminservice.properties.JwtProperties;
import com.elysia.adminservice.result.Result;
import com.elysia.adminservice.service.IGameNewsService;
import com.elysia.adminservice.untils.JwtUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@RequiredArgsConstructor
@Service
@Slf4j
public class IGameNewsServiceImpl implements IGameNewsService {
    private final JwtProperties jwtProperties;
    @Override
    public Result<String> getFileUploadToken(Long userId) {
        // 置入所需数据
        Map<String, Object> claims = new HashMap<>();
        claims.put("id", userId);
        claims.put("type", ResourceTypeEnum.GAME_NEWS.getValue());
        String jwt = JwtUtils.createJWT(jwtProperties.getFileSecretKey(), jwtProperties.getFileTtl(), claims);
        return Result.success(jwt);
    }
}
